package com.模板模式;

import com.模板模式.service.ExportGoodsServiceImpl;
import com.模板模式.service.ExportOrderServiceImpl;
import com.模板模式.service.ExportSuperService;
import com.模板模式.service.ExportUserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.PostConstruct;
import java.util.concurrent.ConcurrentHashMap;

@Service
public class Fatory {

    @Autowired
    ExportGoodsServiceImpl exportGoodsService;
    @Autowired
    ExportOrderServiceImpl exportOrderService;
    @Autowired
    ExportUserServiceImpl exportUserService;

    private static ConcurrentHashMap<String, ExportSuperService> concurrentHashMap=new ConcurrentHashMap<>();
    @PostConstruct
    public void init(){
        concurrentHashMap.put(ExportEnum.GOODS.toString(),exportGoodsService);
        concurrentHashMap.put(ExportEnum.ORDER.toString(),exportOrderService);
        concurrentHashMap.put(ExportEnum.USER.toString(),exportUserService);
    }

    public static ExportSuperService get(ExportEnum exportEnum){
        return concurrentHashMap.get(exportEnum.toString());
    }
}
